def test_to_jar(self):
        version = str(object())
        filename = JAR_FILENAME % version
        jar_out = VanillaJarDownloader._to_jar(filename)

        T.assert_isinstance(jar_out, Jar)
        T.assert_equal(jar_out.filename, filename)
        T.assert_equal(jar_out.short_version, version)
示例#2
0
 def test_unpickleable(self):
     err = Exception(unpickleable)
     try:
         raise err
     except:
         ec = exception_handling.ExceptionContext.current()
     cPickle.dumps(ec)  # make sure it can indeed be serialized
     testify.assert_isinstance(ec, exception_handling.ExceptionContext)
     testify.assert_isinstance(ec.value, Exception)
     testify.assert_equal(str(ec.value), "UNPICKLEABLE AND UNSERIALIZABLE MESSAGE")
    def test_white_user_rating_history_fetch(self):
        fetcher = UserRatingHistoryFetcher(self.white_user.username)
        rating_history = fetcher.get_user_rating_history()

        T.assert_isinstance(rating_history, list)
        T.assert_equal(
            rating_history,
            [
                {
                    "elo": self.game.white_elo,
                    "date_played": {
                        "day": self.game.date_played.day,
                        "month": self.game.date_played.month,
                        "year": self.game.date_played.year
                    },
                    "chess_dot_com_id": self.game.chess_dot_com_id
                }
            ]
        )
示例#4
0
    def test_unpickleable_with_uninitializable_exception(self):
        """
        Tests an exception that can't be pickled (due to CustomException
        not being in global variables) and one that can't be reinitialized
        with a single string argument.
        """
        class CustomException(Exception):
            def __init__(self, a, b):
                self.a, self.b = a, b

            def __str__(self):
                return "{0}, {1}".format(self.a, self.b)

        err = CustomException(3, 4)
        try:
            raise err
        except:
            ec = exception_handling.ExceptionContext.current()
        cPickle.dumps(ec)  # make sure it can indeed be serialized
        testify.assert_isinstance(ec.value, exception_handling.UnpickleableException)
        testify.assert_equal(str(ec.value), "CustomException: 3, 4")
示例#5
0
def assert_json_structure(json_object):
    T.assert_equal(
        json_object,
        {
            'versions': mock.ANY, # Tested more explicitly below
            'latest': {
                RELEASE: mock.ANY,
                SNAPSHOT: mock.ANY,
            }
        }
    )

    # Versions should be a list of dict objects
    T.assert_isinstance(json_object['versions'], list)
    for version_dict in json_object['versions']:
        T.assert_equal(
            version_dict,
            {
                'releaseTime': mock.ANY,
                'type': mock.ANY,
                'id': mock.ANY,
                'time': mock.ANY,
            }
        )
示例#6
0
 def assert_is_pyquery(self, element):
     T.assert_isinstance(element, pyquery.PyQuery)
示例#7
0
 def test_unbound_cached_property(self):
     # Make sure we don't blow up when accessing the property unbound
     prop = self.Foo.foo
     T.assert_isinstance(prop, cached_property)
 def test_return_value_is_testing_response(self):
     instance = TestingClient(None)
     ret = instance.open('/')
     T.assert_isinstance(ret, TestingResponse)