Example #1
0
 def test_add_with_empty(self):
     update = Update([], self.config)
     req_file = Mock()
     req = Mock()
     req.key = "django"
     req.is_pinned = False
     req.latest_version_within_specs = "1.10"
     update.add(req, req_file)
     self.assertEqual("django-pin" in update, True)
     self.assertEqual(len(update["django-pin"]), 1)
Example #2
0
 def test_add_with_empty(self):
     update = Update([])
     req_file = Mock()
     req = Mock()
     req.key = "django"
     req.is_pinned = False
     req.latest_version_within_specs = "1.10"
     update.add(req, req_file)
     self.assertEqual("django-pin" in update, True)
     self.assertEqual(len(update["django-pin"]), 1)
Example #3
0
 def test_unpinned_requirement(self):
     req = Mock()
     req.key = "django"
     req.is_pinned = False
     req.latest_version_within_specs = "1.10"
     self.assertEqual(Update.get_commit_message(req),
                      "Pin django to latest version 1.10")
Example #4
0
 def test_pinned_requirement(self):
     req = Mock()
     req.key = "django"
     req.is_pinned = True
     req.latest_version_within_specs = "1.10"
     req.version = "1.0"
     self.assertEqual(Update.get_commit_message(req), "Update django from 1.0 to 1.10")
Example #5
0
class ShouldUpdateTest(TestCase):
    def setUp(self):
        self.config = Config()

        self.req1 = Mock()
        self.req1.key = "foo"
        self.req1.latest_version_within_specs = "0.2"
        self.req1.needs_update = True
        self.req1.is_pinned = True
        self.req1.is_insecure = False

        self.req2 = Mock()
        self.req2.key = "bar"
        self.req2.latest_version_within_specs = "0.2"
        self.req2.needs_update = True
        self.req2.is_pinned = True
        self.req2.is_insecure = False

        self.req_file = Mock()
        self.req_file.requirements = [self.req1, self.req2]
        self.req_file.path = "requirements.txt"

        self.update = Update(requirement_files=[self.req_file],
                             config=self.config)

    def test_default_yes(self):
        self.assertTrue(self.update.should_update(self.req1, self.req_file))

    def test_update_all_restricted_in_file(self):
        self.assertTrue(self.update.should_update(self.req1, self.req_file))

        self.config.requirements = [
            RequirementConfig(path="requirements.txt", update="insecure")
        ]
        self.assertFalse(self.update.should_update(self.req1, self.req_file))

    def test_update_insecure(self):
        self.config.update = "insecure"
        self.assertFalse(self.update.should_update(self.req1, self.req_file))

        self.req1.is_insecure = True
        self.assertTrue(self.update.should_update(self.req1, self.req_file))

    def test_update_unpinned(self):
        self.config.update = "all"
        self.config.pin = False
        self.req1.is_pinned = False

        self.assertFalse(self.update.should_update(self.req1, self.req_file))

        self.req1.is_pinned = True
        self.assertTrue(self.update.should_update(self.req1, self.req_file))

        self.req1.is_pinned = False
        self.config.pin = True
        self.assertTrue(self.update.should_update(self.req1, self.req_file))
Example #6
0
 def test_pinned_requirement(self):
     req = Mock()
     req.key = "django"
     req.is_pinned = True
     req.latest_version_within_specs = "1.10"
     req.version = "1.0"
     self.assertEqual(Update.get_commit_message(req),
                      "Update django from 1.0 to 1.10")
Example #7
0
    def setUp(self):
        self.config = Config()

        self.req1 = Mock()
        self.req1.key = "foo"
        self.req1.latest_version_within_specs = "0.2"
        self.req1.needs_update = True
        self.req1.is_pinned = True
        self.req1.is_insecure = False

        self.req2 = Mock()
        self.req2.key = "bar"
        self.req2.latest_version_within_specs = "0.2"
        self.req2.needs_update = True
        self.req2.is_pinned = True
        self.req2.is_insecure = False

        self.req_file = Mock()
        self.req_file.requirements = [self.req1, self.req2]
        self.req_file.path = "requirements.txt"

        self.update = Update(requirement_files=[self.req_file],
                             config=self.config)
Example #8
0
 def test_class(self):
     update = Update([], self.config)
     self.assertEqual(RequirementUpdate,
                      update.get_requirement_update_class())
Example #9
0
 def test_init_with_reqs(self):
     with patch("pyup.requirements.Requirement") as req:
         req.needs_update = True
         req_files = [RequirementFile("req.txt", "django")]
         update = Update(req_files, self.config)
         self.assertEqual(len(update.keys()), 1)
Example #10
0
 def test_init_empty(self):
     update = Update([], self.config)
     self.assertEqual(update, dict())
Example #11
0
 def test_unpinned_requirement(self):
     req = Mock()
     req.key = "django"
     req.is_pinned = False
     req.latest_version_within_specs = "1.10"
     self.assertEqual(Update.get_commit_message(req), "Pin django to latest version 1.10")
Example #12
0
 def test_unpinned_requirement(self):
     req = Mock()
     req.key = "django"
     req.is_pinned = False
     self.assertEqual(Update.create_update_key(req), "django-pin")
Example #13
0
 def test_class(self):
     update = Update([])
     self.assertEqual(RequirementUpdate, update.get_requirement_update_class())
Example #14
0
 def test_init_with_reqs(self):
     with patch("pyup.requirements.Requirement") as req:
         req.needs_update = True
         req_files = [RequirementFile("req.txt", "django")]
         update = Update(req_files)
         self.assertEqual(len(update.keys()), 1)
Example #15
0
 def test_unpinned_requirement(self):
     req = Mock()
     req.key = "django"
     req.is_pinned = False
     self.assertEqual(Update.create_update_key(req), "django-pin")
Example #16
0
 def test_latest_version_within_specs(self):
     req = Mock()
     req.key = "django"
     req.is_pinned = True
     req.latest_version_within_specs = "1.10"
     self.assertEqual(Update.create_update_key(req), "django-1.10")
Example #17
0
 def test_latest_version_within_specs(self):
     req = Mock()
     req.key = "django"
     req.is_pinned = True
     req.latest_version_within_specs = "1.10"
     self.assertEqual(Update.create_update_key(req), "django-1.10")