Ejemplo n.º 1
0
    def test_find_all(self, profile_dao_find_all):
        profile1 = CtiProfile()
        profile2 = CtiProfile()
        profile_dao_find_all.return_value = [profile1, profile2]

        [res1, res2] = services.find_all()

        assert_that(res1, same_instance(profile1))
        assert_that(res2, same_instance(profile2))
Ejemplo n.º 2
0
    def testMismatchDescriptionShowsActualArgumentAddress(self):
        matcher = same_instance("foo")
        description = StringDescription()
        expected = re.compile("was " + ADDRESS_FORMAT + " 'hi'")

        result = matcher.matches("hi", description)
        self.assertFalse(result, "Precondition: Matcher should not match item")
        self.assertTrue(expected.match(str(description)))
Ejemplo n.º 3
0
    def test_get(self, profile_dao_get):
        profile = CtiProfile()
        profile_dao_get.return_value = profile

        result = services.get(1)

        assert_that(result, same_instance(profile))
        profile_dao_get.assert_called_with(1)
Ejemplo n.º 4
0
    def testDescribeMismatch(self):
        matcher = same_instance("foo")
        description = StringDescription()
        expected = re.compile("was " + ADDRESS_FORMAT + " 'hi'")

        matcher.describe_mismatch("hi", description)
        expected = re.compile("was " + ADDRESS_FORMAT + " 'hi'")
        self.assertTrue(
            expected.match(str(description)),
            "Expected %s to match %s" % (str(matcher), str(description)),
        )
Ejemplo n.º 5
0
 def testDescribeMismatchWithNilShouldNotIncludeAddress(self):
     self.assert_describe_mismatch("was <None>", same_instance("foo"), None)
Ejemplo n.º 6
0
 def testMismatchDescriptionWithNilShouldNotIncludeAddress(self):
     self.assert_mismatch_description("was <None>", same_instance("foo"), None)
Ejemplo n.º 7
0
 def testSuccessfulMatchDoesNotGenerateMismatchDescription(self):
     o1 = object()
     self.assert_no_mismatch_description(same_instance(o1), o1)
Ejemplo n.º 8
0
    def testDescriptionIncludesMemoryAddress(self):
        description = StringDescription()
        expected = re.compile("same instance as " + ADDRESS_FORMAT + " 'abc'")

        description.append_description_of(same_instance("abc"))
        self.assertTrue(expected.match(str(description)))
Ejemplo n.º 9
0
    def testEvaluatesToTrueIfArgumentIsReferenceToASpecifiedObject(self):
        o1 = object()
        o2 = object()

        self.assert_matches("same", same_instance(o1), o1)
        self.assert_does_not_match("different", same_instance(o1), o2)