Ejemplo n.º 1
0
 def test_success_with_data_dir(self):
     content = self.generate_content()
     with patch.object(config, "data_dir", self.base_dir):
         store_local_copy("%s/bar", self.participation, self.task,
                          self.timestamp, {"foo.%l": content})
     self.assertSomeFileContains(content,
                                 in_=os.path.join(self.base_dir, "bar"))
Ejemplo n.º 2
0
 def test_success(self):
     # We use a content that is unique enough to ensure that if we
     # find it in a file it won't be a false positive.
     content = self.generate_content()
     directory = os.path.join(self.base_dir, "foo")
     store_local_copy(directory, self.participation, self.task,
                      self.timestamp, {"foo.%l": content})
     self.assertSomeFileContains(content, in_=directory)
Ejemplo n.º 3
0
 def test_success_many_times(self):
     # Test that multiple files are allowed in a single call and that
     # successive calls don't overwrite preceding ones.
     content_a = self.generate_content()
     content_b = self.generate_content()
     content_c = self.generate_content()
     store_local_copy(self.base_dir, self.participation, self.task,
                      self.timestamp,
                      {"foo.%l": content_a, "bar.txt": content_b})
     # Giving the same user and timestamp would actually overwrite.
     store_local_copy(self.base_dir, self.participation, self.task,
                      self.timestamp + timedelta(seconds=1),
                      {"foo.%l": content_c})
     self.assertSomeFileContains(content_a, in_=self.base_dir)
     self.assertSomeFileContains(content_b, in_=self.base_dir)
     self.assertSomeFileContains(content_c, in_=self.base_dir)
Ejemplo n.º 4
0
 def test_failure(self):
     # Make read-only.
     os.chmod(self.base_dir, stat.S_IRUSR)
     with self.assertRaises(StorageFailed):
         store_local_copy(self.base_dir, self.participation, self.task,
                          self.timestamp, {"foo.%l": b"some content"})