test/unit/service/serialization_test.rb in azure-0.6.4 vs test/unit/service/serialization_test.rb in azure-0.7.0.pre
- old
+ new
@@ -212,11 +212,11 @@
builder.to_xml.must_equal retention_policy_xml
end
end
describe "#retention_policy_from_xml" do
- let(:retention_policy_xml) { Nokogiri.Slop(Fixtures["storage_service_properties"]).root.Metrics.RetentionPolicy }
+ let(:retention_policy_xml) { Nokogiri.Slop(Fixtures["storage_service_properties"]).root.HourMetrics.RetentionPolicy }
it "accepts an XML Node" do
subject.retention_policy_from_xml retention_policy_xml
end
@@ -231,11 +231,11 @@
retention_policy.enabled.must_equal true
retention_policy.days.must_equal 7
end
end
- describe "#metrics_to_xml" do
+ describe "#hour_metrics_to_xml" do
let(:metrics) {
metrics = Azure::Service::Metrics.new
metrics.version = "1.0"
metrics.enabled = true
metrics.include_apis = false
@@ -248,24 +248,24 @@
let(:metrics_xml) { Fixtures["metrics"]}
it "accepts a Metrics instance and an Nokogiri::XML::Builder instance" do
Nokogiri::XML::Builder.new do |xml|
- subject.metrics_to_xml metrics, xml
+ subject.hour_metrics_to_xml metrics, xml
end
end
it "adds to the XML Builder, which will create the XML graph of the provided values" do
builder = Nokogiri::XML::Builder.new do |xml|
- subject.metrics_to_xml metrics, xml
+ subject.hour_metrics_to_xml metrics, xml
end
builder.to_xml.must_equal metrics_xml
end
end
describe "#metrics_from_xml" do
- let(:metrics_xml) { Nokogiri.Slop(Fixtures["storage_service_properties"]).root.Metrics }
+ let(:metrics_xml) { Nokogiri.Slop(Fixtures["storage_service_properties"]).root.HourMetrics }
let(:mock_retention_policy) { mock }
before {
subject.expects(:retention_policy_from_xml).returns(mock_retention_policy)
}
@@ -360,18 +360,47 @@
logging.write = true
retention_policy = logging.retention_policy = Azure::Service::RetentionPolicy.new
retention_policy.enabled = true
retention_policy.days = 7
- metrics = service_properties.metrics = Azure::Service::Metrics.new
+ metrics = service_properties.hour_metrics = Azure::Service::Metrics.new
metrics.version = "1.0"
metrics.enabled = true
metrics.include_apis = false
retention_policy = metrics.retention_policy = Azure::Service::RetentionPolicy.new
retention_policy.enabled = true
retention_policy.days = 7
+ service_properties.minute_metrics = metrics
+
+ service_properties.cors = Azure::Service::Cors.new do |cors|
+ cors.cors_rules = []
+ cors.cors_rules.push(Azure::Service::CorsRule.new { |cors_rule|
+ cors_rule.allowed_origins = ["http://www.contoso.com", "http://dummy.uri"]
+ cors_rule.allowed_methods = ["PUT", "HEAD"]
+ cors_rule.max_age_in_seconds = 5
+ cors_rule.exposed_headers = ["x-ms-*"]
+ cors_rule.allowed_headers = ["x-ms-blob-content-type", "x-ms-blob-content-disposition"]
+ })
+
+ cors.cors_rules.push(Azure::Service::CorsRule.new { |cors_rule|
+ cors_rule.allowed_origins = ["*"]
+ cors_rule.allowed_methods = ["PUT", "GET"]
+ cors_rule.max_age_in_seconds = 5
+ cors_rule.exposed_headers = ["x-ms-*"]
+ cors_rule.allowed_headers = ["x-ms-blob-content-type", "x-ms-blob-content-disposition"]
+ })
+
+ cors.cors_rules.push(Azure::Service::CorsRule.new { |cors_rule|
+ cors_rule.allowed_origins = ["http://www.contoso.com"]
+ cors_rule.allowed_methods = ["GET"]
+ cors_rule.max_age_in_seconds = 5
+ cors_rule.exposed_headers = ["x-ms-*"]
+ cors_rule.allowed_headers = ["x-ms-client-request-id"]
+ })
+ end
+
service_properties
}
let(:service_properties_xml) { Fixtures["storage_service_properties"]}
@@ -387,14 +416,16 @@
describe "#service_properties_from_xml" do
let(:service_properties_xml) { Fixtures["storage_service_properties"]}
let(:mock_logging) { mock }
let(:mock_metrics) { mock }
+ let(:mock_cors) { mock }
before {
subject.expects(:logging_from_xml).returns(mock_logging)
- subject.expects(:metrics_from_xml).returns(mock_metrics)
+ subject.expects(:metrics_from_xml).twice.returns(mock_metrics)
+ subject.expects(:cors_from_xml).returns(mock_cors)
}
it "accepts an XML string" do
subject.service_properties_from_xml service_properties_xml
end
@@ -405,12 +436,12 @@
service_properties.must_be_kind_of Azure::Service::StorageServiceProperties
end
it "sets the properties of the StorageServiceProperties instance" do
service_properties = subject.service_properties_from_xml service_properties_xml
- service_properties.default_service_version.must_equal "2011-08-18"
service_properties.logging.must_equal mock_logging
- service_properties.metrics.must_equal mock_metrics
+ service_properties.hour_metrics.must_equal mock_metrics
+ service_properties.minute_metrics.must_equal mock_metrics
end
end
describe "#to_bool" do
it "converts a valid string value to a Boolean" do
\ No newline at end of file