datetime.

Here are the examples of the python api datetime. taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

188 Examples 7

Example 1

Project: django-pki
Source File: __init__.py
View license
    def setUp(self):
        self.obj = CertificateAuthority(common_name='Root CA', name='Root_CA', description="unittest", country='DE', state='Bavaria', \
                                        locality='Munich', organization='Bozo Clown Inc.', OU='IT', email='[email protected]', valid_days=1000, \
                                        key_length=1024, expiry_date=datetime.datetime(2021, 01, 01, 20, 00, 00).date(), \
                                        created=datetime.datetime(2011, 01, 01, 20, 00, 00), \
                                        revoked=datetime.datetime(2011, 01, 01, 20, 00, 00), active=None, serial=None, ca_chain=None, \
                                        der_encoded=False, parent=None, passphrase='1234567890', id=999)

Example 2

Project: onearth
Source File: test_mod_onearth.py
View license
    def test_snapping_5a(self):
        layer_name = 'snap_test_5a'
        expected_date = datetime.date(2002, 12, 01)
        while (expected_date.year < 2012):
            end_date = expected_date.replace(year=expected_date.year + 1) + datetime.timedelta(days=-1)
            req_date = expected_date
            while (req_date < end_date):
                req_url = self.snap_test_url_template.format(layer_name, req_date)
                response_date = test_snap_request(self.tile_hashes, req_url)
                error = 'Snapping test 5a requested date {0}, expected {1}, but got {2}. \nURL: {3}'.format(req_date.isoformat(), expected_date.isoformat(), response_date, req_url)
                self.assertEqual(expected_date.isoformat(), response_date, error)
                req_date += datetime.timedelta(days=+1)
            expected_date = expected_date.replace(expected_date.year + 1)

Example 3

Project: zamboni
Source File: tests.py
View license
    def setUp(self):
        super(TestMonolithResource, self).setUp()
        self.grant_permission(self.profile, 'Monolith:API')
        self.list_url = reverse('monolith-list')
        self.now = datetime.datetime(2013, 02, 12, 17, 34)
        self.last_month = self.now - datetime.timedelta(days=30)
        self.last_week = self.now - datetime.timedelta(days=7)
        self.yesterday = self.now - datetime.timedelta(days=1)
        self.date_format = '%Y-%m-%d'
        self.request = RequestFactory()

Example 4

Project: medicare-demo
Source File: test_xmlrpc.py
View license
    def test_dump_bare_time(self):
        # This checks that an unwrapped datetime.time object can be handled
        # by the marshalling code.  This can't be done via test_dump_load()
        # since the unmarshaller produces a datetime object
        t = datetime.datetime(2005, 02, 10, 11, 41, 23).time()
        s = xmlrpclib.dumps((t,))
        (newt,), m = xmlrpclib.loads(s, use_datetime=1)
        today = datetime.datetime.now().date().strftime("%Y%m%d")
        self.assertEquals(newt.time(), t)
        self.assertEquals(newt.date(), datetime.datetime.now().date())
        self.assertEquals(m, None)

        (newdt,), m = xmlrpclib.loads(s, use_datetime=0)
        self.assertEquals(newdt, xmlrpclib.DateTime('%sT11:41:23'%today))

Example 5

Project: medicare-demo
Source File: test_xmlrpc.py
View license
    def test_dump_bare_date(self):
        # This checks that an unwrapped datetime.date object can be handled
        # by the marshalling code.  This can't be done via test_dump_load()
        # since the unmarshaller produces a datetime object
        d = datetime.datetime(2005, 02, 10, 11, 41, 23).date()
        s = xmlrpclib.dumps((d,))
        (newd,), m = xmlrpclib.loads(s, use_datetime=1)
        self.assertEquals(newd.date(), d)
        self.assertEquals(newd.time(), datetime.time(0, 0, 0))
        self.assertEquals(m, None)

        (newdt,), m = xmlrpclib.loads(s, use_datetime=0)
        self.assertEquals(newdt, xmlrpclib.DateTime('20050210T00:00:00'))

Example 6

Project: onearth
Source File: test_mod_onearth.py
View license
    def test_snapping_5a(self):
        layer_name = 'snap_test_5a'
        expected_date = datetime.date(2002, 12, 01)
        while (expected_date.year < 2012):
            end_date = expected_date.replace(year=expected_date.year + 1) + datetime.timedelta(days=-1)
            req_date = expected_date
            while (req_date < end_date):
                req_url = self.snap_test_url_template.format(layer_name, req_date)
                response_date = test_snap_request(self.tile_hashes, req_url)
                error = 'Snapping test 5a requested date {0}, expected {1}, but got {2}. \nURL: {3}'.format(req_date.isoformat(), expected_date.isoformat(), response_date, req_url)
                self.assertEqual(expected_date.isoformat(), response_date, error)
                req_date += datetime.timedelta(days=+1)
            expected_date = expected_date.replace(expected_date.year + 1)

Example 7

Project: dissemin
Source File: testcrossref.py
View license
    def test_parse_crossref_date_incomplete(self):
        self.assertEqual(parse_crossref_date(None), None)
        self.assertEqual(
                parse_crossref_date({'date-parts': [[2015, 07, 06]]}),
                datetime.date(year=2015, month=07, day=06))
        self.assertEqual(
                parse_crossref_date({'date-parts': [[2015, 07]]}),
                datetime.date(year=2015, month=07, day=01))
        self.assertEqual(
                parse_crossref_date({'date-parts': [[2015]]}),
                datetime.date(year=2015, month=01, day=01))

Example 8

Project: dissemin
Source File: testcrossref.py
View license
    def test_parse_crossref_date_raw(self):
        self.assertEqual(
                parse_crossref_date({'raw': '2015'}),
                datetime.date(year=2015, month=01, day=01))
        self.assertEqual(
                parse_crossref_date({'raw': '2015-07'}),
                datetime.date(year=2015, month=07, day=01))
        self.assertEqual(
                parse_crossref_date({'raw': '2015-07-06'}),
                datetime.date(year=2015, month=07, day=06))

Example 9

Project: django-pki
Source File: __init__.py
View license
    def setUp(self):
        self.obj = CertificateAuthority(common_name='Root CA', name='Root_CA', description="unittest", country='DE', state='Bavaria', \
                                        locality='Munich', organization='Bozo Clown Inc.', OU='IT', email='[email protected]', valid_days=1000, \
                                        key_length=1024, expiry_date=datetime.datetime(2021, 01, 01, 20, 00, 00).date(), \
                                        created=datetime.datetime(2011, 01, 01, 20, 00, 00), revoked=datetime.datetime(2011, 01, 01, 20, 00, 00), \
                                        active=None, serial=None, ca_chain=None, der_encoded=False, parent=None, passphrase='1234567890', id=999)

Example 10

Project: babble
Source File: test_xmlrpc.py
View license
    def test_dump_bare_date(self):
        # This checks that an unwrapped datetime.date object can be handled
        # by the marshalling code.  This can't be done via test_dump_load()
        # since the unmarshaller produces a datetime object
        d = datetime.datetime(2005, 02, 10, 11, 41, 23).date()
        s = xmlrpclib.dumps((d,))
        (newd,), m = xmlrpclib.loads(s, use_datetime=1)
        self.assertEquals(newd.date(), d)
        self.assertEquals(newd.time(), datetime.time(0, 0, 0))
        self.assertEquals(m, None)

        (newdt,), m = xmlrpclib.loads(s, use_datetime=0)
        self.assertEquals(newdt, xmlrpclib.DateTime('20050210T00:00:00'))

Example 11

Project: acousticbrainz-server
Source File: test_stats.py
View license
    def test_get_next_hour(self):
        date1 = datetime.datetime(2016, 01, 07, 10, 20, 39, tzinfo=pytz.utc)
        next_hour = db.stats._get_next_hour(date1)
        expected = datetime.datetime(2016, 01, 07, 11, 0, 0, tzinfo=pytz.utc)
        self.assertEqual(next_hour, expected)

        date2 = datetime.datetime(2016, 01, 07, 13, 0, 0, tzinfo=pytz.utc)
        next_hour = db.stats._get_next_hour(date2)
        expected = datetime.datetime(2016, 01, 07, 14, 0, 0, tzinfo=pytz.utc)
        self.assertEqual(next_hour, expected)

Example 12

Project: babble
Source File: test_xmlrpc.py
View license
    def test_dump_bare_time(self):
        # This checks that an unwrapped datetime.time object can be handled
        # by the marshalling code.  This can't be done via test_dump_load()
        # since the unmarshaller produces a datetime object
        t = datetime.datetime(2005, 02, 10, 11, 41, 23).time()
        s = xmlrpclib.dumps((t,))
        (newt,), m = xmlrpclib.loads(s, use_datetime=1)
        today = datetime.datetime.now().date().strftime("%Y%m%d")
        self.assertEquals(newt.time(), t)
        self.assertEquals(newt.date(), datetime.datetime.now().date())
        self.assertEquals(m, None)

        (newdt,), m = xmlrpclib.loads(s, use_datetime=0)
        self.assertEquals(newdt, xmlrpclib.DateTime('%sT11:41:23'%today))

Example 13

Project: zamboni
Source File: tests.py
View license
    def setUp(self):
        super(TestMonolithResource, self).setUp()
        self.grant_permission(self.profile, 'Monolith:API')
        self.list_url = reverse('monolith-list')
        self.now = datetime.datetime(2013, 02, 12, 17, 34)
        self.last_month = self.now - datetime.timedelta(days=30)
        self.last_week = self.now - datetime.timedelta(days=7)
        self.yesterday = self.now - datetime.timedelta(days=1)
        self.date_format = '%Y-%m-%d'
        self.request = RequestFactory()

Example 14

Project: acousticbrainz-server
Source File: test_stats.py
View license
    def test_get_next_hour(self):
        date1 = datetime.datetime(2016, 01, 07, 10, 20, 39, tzinfo=pytz.utc)
        next_hour = db.stats._get_next_hour(date1)
        expected = datetime.datetime(2016, 01, 07, 11, 0, 0, tzinfo=pytz.utc)
        self.assertEqual(next_hour, expected)

        date2 = datetime.datetime(2016, 01, 07, 13, 0, 0, tzinfo=pytz.utc)
        next_hour = db.stats._get_next_hour(date2)
        expected = datetime.datetime(2016, 01, 07, 14, 0, 0, tzinfo=pytz.utc)
        self.assertEqual(next_hour, expected)

Example 15

Project: fitbit_tools
Source File: fitbit.date.py
View license
def check_day( date='' ):
    if date == '' :
        date = datetime.date( 2012,06,20 )
    datestr = date.strftime("%Y-%m-%d")
    db = mydb.Database()
    sql = "SELECT * FROM fitbit_daily WHERE datestamp = %s "
    out = db.db_array( sql , ( datestr ) )
    return len(out)

Example 16

Project: inferno
Source File: test_map.py
View license
    def setUp(self):
        self.data = {
            'city': 'toronto',
            'country': 'canada',
            'population': 100,
            'size': 1000,
            'date': datetime.date(2012, 12, 01)}
        self.rule = InfernoRule(
            key_parts=['country', 'city'],
            value_parts=['population', 'size'])

Example 17

Project: imagrium
Source File: test_xmlrpc.py
View license
    def test_dump_bare_datetime(self):
        # This checks that an unwrapped datetime.date object can be handled
        # by the marshalling code.  This can't be done via test_dump_load()
        # since with use_datetime set to 1 the unmarshaller would create
        # datetime objects for the 'datetime[123]' keys as well
        dt = datetime.datetime(2005, 02, 10, 11, 41, 23)
        s = xmlrpclib.dumps((dt,))
        (newdt,), m = xmlrpclib.loads(s, use_datetime=1)
        self.assertEqual(newdt, dt)
        self.assertEqual(m, None)

        (newdt,), m = xmlrpclib.loads(s, use_datetime=0)
        self.assertEqual(newdt, xmlrpclib.DateTime('20050210T11:41:23'))

Example 18

Project: pymo
Source File: test_xmlrpc.py
View license
    def test_datetime_before_1900(self):
        # same as before but with a date before 1900
        dt = datetime.datetime(1, 02, 10, 11, 41, 23)
        s = xmlrpclib.dumps((dt,))
        (newdt,), m = xmlrpclib.loads(s, use_datetime=1)
        self.assertEqual(newdt, dt)
        self.assertEqual(m, None)

        (newdt,), m = xmlrpclib.loads(s, use_datetime=0)
        self.assertEqual(newdt, xmlrpclib.DateTime('00010210T11:41:23'))

Example 19

Project: openwrt-mt7620
Source File: test_xmlrpc.py
View license
    def test_dump_bare_datetime(self):
        # This checks that an unwrapped datetime.date object can be handled
        # by the marshalling code.  This can't be done via test_dump_load()
        # since with use_datetime set to 1 the unmarshaller would create
        # datetime objects for the 'datetime[123]' keys as well
        dt = datetime.datetime(2005, 02, 10, 11, 41, 23)
        s = xmlrpclib.dumps((dt,))
        (newdt,), m = xmlrpclib.loads(s, use_datetime=1)
        self.assertEqual(newdt, dt)
        self.assertEqual(m, None)

        (newdt,), m = xmlrpclib.loads(s, use_datetime=0)
        self.assertEqual(newdt, xmlrpclib.DateTime('20050210T11:41:23'))

Example 20

Project: imagrium
Source File: test_xmlrpc.py
View license
    def test_datetime_before_1900(self):
        # same as before but with a date before 1900
        dt = datetime.datetime(1, 02, 10, 11, 41, 23)
        s = xmlrpclib.dumps((dt,))
        (newdt,), m = xmlrpclib.loads(s, use_datetime=1)
        self.assertEqual(newdt, dt)
        self.assertEqual(m, None)

        (newdt,), m = xmlrpclib.loads(s, use_datetime=0)
        self.assertEqual(newdt, xmlrpclib.DateTime('00010210T11:41:23'))

Example 21

Project: dissemin
Source File: tests.py
View license
    def test_update_authors(self):
        for old_author_names, new_author_names, final in [
                ([('G.', 'Bodenhausen')],
                 [('Geoffrey', 'Bodenhausen')],
                 [('Geoffrey', 'Bodenhausen')]),
                ([('L. F.', 'Jullien'), ('A.', 'Amarilli')],
                 [('Ludovic', 'Jullien'), ('R.', 'Pérand'), ('Antoine', 'Amarilli')],
                 [('Ludovic F.', 'Jullien'), ('R.', 'Pérand'), ('Antoine', 'Amarilli')]),
                ]:
            paper = Paper.get_or_create('This is a test paper',
                                        [BareName.create_bare(f, l) for (
                                            f, l) in old_author_names],
                                        datetime.date(year=2015, month=04, day=05))
            new_authors = [BareAuthor(name=BareName.create_bare(f, l))
                           for (f, l) in new_author_names]
            paper.update_authors(new_authors)
            self.assertEqual(paper.bare_author_names(), final)

Example 22

Project: dissemin
Source File: tests.py
View license
    def test_find_duplicate_records_invalid_url(self):
        paper = Paper.get_or_create('this is a title', [Name.lookup_name(('Jean', 'Saisrien'))],
                                    datetime.date(year=2015, month=05, day=04))
        # This used to throw an exception
        OaiRecord.find_duplicate_records(
            paper, 'ftp://dissem.in/paper.pdf', None)

Example 23

Project: flvlib
Source File: test_helpers.py
View license
    def test_datetime(self):
        date = datetime.datetime(1990, 01, 02, 20, 30, 22)
        self.assertEquals(self.pp.pformat(date), "1990-01-02 20:30:22")

        self.assertEquals(self.pp.pformat(date.replace(tzinfo=helpers.utc)),
                                          "1990-01-02 20:30:22+00:00")

Example 24

View license
    def test_task_urls(self):
        date = datetime.date(2013, 01, 20)

        task = EnrollmentsByWeek(name='fake_name',
                                 src=['s3://bucket/path/'],
                                 offsets='s3://bucket/file.txt',
                                 destination='file://path/file.txt',
                                 date=date)

        requires = task.requires()

        source = requires['source'].output()
        offsets = requires['offsets'].output()
        self.assertIsInstance(offsets, luigi.hdfs.HdfsTarget)
        self.assertEqual(offsets.format, luigi.hdfs.Plain)

        destination = task.output()
        self.assertIsInstance(destination, luigi.File)

Example 25

Project: huxley
Source File: test_log.py
View license
    def test_valid(self):
        log_entry = LogEntry.objects.create(
            level='DEBUG',
            message='This is a message',
            timestamp=datetime.datetime(2015, 05, 27),
            uri="/some/random/uri",
            status_code=200,
            username='username')

        self.assertEqual(log_entry.level, 'DEBUG')
        self.assertEqual(log_entry.message, 'This is a message')
        self.assertEqual(log_entry.timestamp, datetime.datetime(2015, 05, 27))
        self.assertEqual(log_entry.uri, "/some/random/uri")
        self.assertEqual(log_entry.status_code, 200)
        self.assertEqual(log_entry.username, 'username')

Example 26

Project: openwrt-mt7620
Source File: test_xmlrpc.py
View license
    def test_datetime_before_1900(self):
        # same as before but with a date before 1900
        dt = datetime.datetime(1, 02, 10, 11, 41, 23)
        s = xmlrpclib.dumps((dt,))
        (newdt,), m = xmlrpclib.loads(s, use_datetime=1)
        self.assertEqual(newdt, dt)
        self.assertEqual(m, None)

        (newdt,), m = xmlrpclib.loads(s, use_datetime=0)
        self.assertEqual(newdt, xmlrpclib.DateTime('00010210T11:41:23'))

Example 27

Project: find_times
Source File: find_times.py
View license
def find_uuid(data):
    for i in xrange(len(data)):
        try:
            ts_uuid = uuid.UUID(bytes=data[i:i + 16])
            uuid1time = ts_uuid.time
            ts = dt.datetime.utcfromtimestamp((uuid1time - 0x01b21dd213814000L) * 100 / 1e9)
            yield i, ts
        except ValueError:
            continue

Example 28

Project: simian
Source File: __init___test.py
View license
  def testStrHeaderDateToDatetime(self):
    """Tests StrHeaderDateToDatetime()."""
    header_dt_str = 'Wed, 06 Oct 2010 03:23:34 GMT'
    dt = datetime.datetime(2010, 10, 06, 03, 23, 34)  # same date
    r = handlers.StrHeaderDateToDatetime(header_dt_str)
    self.assertEqual(dt, r)

Example 29

View license
    def test_multiple_problem_attempts_same_problem(self):
        self._check_output_by_record_field(
            [
                self.input_record.to_separated_values(),
                self.input_record.replace(date=datetime.date(2014, 03, 27)).to_separated_values()
            ],
            {
                'problem_attempts': '2',
                'problems_attempted': '1',
                'problem_attempts_per_completed': 'inf',
                'days_active': '2'
            }
        )

Example 30

Project: openwrt-mt7620
Source File: test_xmlrpc.py
View license
    def test_datetime_before_1900(self):
        # same as before but with a date before 1900
        dt = datetime.datetime(1, 02, 10, 11, 41, 23)
        s = xmlrpclib.dumps((dt,))
        (newdt,), m = xmlrpclib.loads(s, use_datetime=1)
        self.assertEqual(newdt, dt)
        self.assertEqual(m, None)

        (newdt,), m = xmlrpclib.loads(s, use_datetime=0)
        self.assertEqual(newdt, xmlrpclib.DateTime('00010210T11:41:23'))

Example 31

Project: chipsec
Source File: test_xmlrpc.py
View license
    def test_datetime_before_1900(self):
        # same as before but with a date before 1900
        dt = datetime.datetime(1, 02, 10, 11, 41, 23)
        s = xmlrpclib.dumps((dt,))
        (newdt,), m = xmlrpclib.loads(s, use_datetime=1)
        self.assertEqual(newdt, dt)
        self.assertEqual(m, None)

        (newdt,), m = xmlrpclib.loads(s, use_datetime=0)
        self.assertEqual(newdt, xmlrpclib.DateTime('00010210T11:41:23'))

Example 32

Project: fitbit_tools
Source File: fitbit.download.py
View license
def check_day( date='' ):
    if date == '' :
        date = datetime.date( 2012,06,20 )
    datestr = date.strftime("%Y-%m-%d")
    db = mydb.Database( 'itap' )
    sql = "SELECT * FROM fitbit_daily WHERE datestamp = %s "
    out = db.db_array( sql , ( datestr ) )
    return len(out)

Example 33

Project: ANALYSE
Source File: test_logger.py
View license
    def test_logger_backend(self):
        self.handler.reset()

        # Send a couple of events and check if they were recorded
        # by the logger. The events are serialized to JSON.

        event = {
            'test': True,
            'time': datetime.datetime(2012, 05, 01, 07, 27, 01, 200),
            'date': datetime.date(2012, 05, 07),
        }

Example 34

Project: dissemin
Source File: testcrossref.py
View license
    def test_get_publication_date(self):
        self.assertEqual(
                get_publication_date(
                    fetch_metadata_by_DOI('10.5281/zenodo.18898')),
                datetime.date(year=2015, month=01, day=01))
        self.assertEqual(
                get_publication_date(
                    fetch_metadata_by_DOI('10.5380/dp.v1i1.1919')),
                datetime.date(year=2005, month=03, day=18))

Example 35

Project: ANALYSE
Source File: test_logger.py
View license
    def test_logger_backend(self):
        self.handler.reset()

        # Send a couple of events and check if they were recorded
        # by the logger. The events are serialized to JSON.

        event = {
            'test': True,
            'time': datetime.datetime(2012, 05, 01, 07, 27, 01, 200),
            'date': datetime.date(2012, 05, 07),
        }

Example 36

Project: babble
Source File: test_xmlrpc.py
View license
    def test_dump_bare_datetime(self):
        # This checks that an unwrapped datetime.date object can be handled
        # by the marshalling code.  This can't be done via test_dump_load()
        # since with use_datetime set to 1 the unmarshaller would create
        # datetime objects for the 'datetime[123]' keys as well
        dt = datetime.datetime(2005, 02, 10, 11, 41, 23)
        s = xmlrpclib.dumps((dt,))
        (newdt,), m = xmlrpclib.loads(s, use_datetime=1)
        self.assertEquals(newdt, dt)
        self.assertEquals(m, None)

        (newdt,), m = xmlrpclib.loads(s, use_datetime=0)
        self.assertEquals(newdt, xmlrpclib.DateTime('20050210T11:41:23'))

Example 37

Project: event-tracking
Source File: test_logger.py
View license
    def test_event_with_datetime_fields(self):
        eastern_tz = pytz.timezone('US/Eastern')
        test_time = datetime.datetime(2012, 05, 01, 07, 27, 01, 200)
        event = {
            'test': True,
            'time': test_time,
            'converted_time': eastern_tz.localize(test_time),
            'date': datetime.date(2012, 05, 07)
        }

Example 38

Project: openwrt-mt7620
Source File: test_xmlrpc.py
View license
    def test_dump_bare_datetime(self):
        # This checks that an unwrapped datetime.date object can be handled
        # by the marshalling code.  This can't be done via test_dump_load()
        # since with use_datetime set to 1 the unmarshaller would create
        # datetime objects for the 'datetime[123]' keys as well
        dt = datetime.datetime(2005, 02, 10, 11, 41, 23)
        s = xmlrpclib.dumps((dt,))
        (newdt,), m = xmlrpclib.loads(s, use_datetime=1)
        self.assertEqual(newdt, dt)
        self.assertEqual(m, None)

        (newdt,), m = xmlrpclib.loads(s, use_datetime=0)
        self.assertEqual(newdt, xmlrpclib.DateTime('20050210T11:41:23'))

Example 39

Project: titan
Source File: utils_test.py
View license
  def testCustomJsonEncoder(self):
    # Test serializing datetimes.
    original = {'test': datetime.datetime(2013, 04, 02, 10, 11, 12, 123)}
    self.assertEqual(
        '{"test": 1364922672.000123}',
        json.dumps(original, cls=utils.CustomJsonEncoder))

    # Test serializing objects with a "serialize" method.
    class Foo(object):

      def serialize(self):
        return 'foo'

    self.assertEqual('"foo"', json.dumps(Foo(), cls=utils.CustomJsonEncoder))

Example 40

Project: simian
Source File: applesus_test.py
View license
  def testGetSuccess(self):
    """Tests AppleSUS.get()."""
    track = 'stable'
    full_os_version = '10.6.6'
    major_minor_os_version = '10.6'
    client_id = {'track': track, 'os_version': full_os_version}
    session = 'session'
    catalog_date = datetime.datetime(2011, 01, 01)

Example 41

Project: allura
Source File: test_webhooks.py
View license
    @patch('allura.model.webhook.dt', autospec=True)
    def test_update_limit(self, dt_mock):
        _now = dt.datetime(2015, 02, 02, 13, 39)
        dt_mock.datetime.utcnow.return_value = _now
        assert_equal(self.wh.last_sent, None)
        self.wh.update_limit()
        session(self.wh).expunge(self.wh)
        assert_equal(M.Webhook.query.get(_id=self.wh._id).last_sent, _now)

Example 42

Project: bbvisa2ofx
Source File: txtparser.py
View license
    def testParseDateFromTransactionLine_guessingYearBefore(self):
        '''
            mesmo mes do vencimento, sugerindo ano anterior
        '''
        line = '25/07    Atlassian              Sydney          AU              0,00       20,00'
        self.parser.dueDate = datetime.datetime(2011,07,25)

        date = self.parser.parseDateFromTransactionLine(line)
        self.assertEquals(date,'20100725')

Example 43

Project: bbvisa2ofx
Source File: txtparser.py
View license
    def testParseDateFromTransactionLine_fromSameYear(self):
        line = '25/02    Atlassian              Sydney          AU              0,00       20,00'
        self.parser.dueDate = datetime.datetime(2011,07,25)

        date = self.parser.parseDateFromTransactionLine(line)
        self.assertEquals(date,'20110225')

Example 44

Project: edx-platform
Source File: test_logger.py
View license
    def test_logger_backend(self):
        self.handler.reset()

        # Send a couple of events and check if they were recorded
        # by the logger. The events are serialized to JSON.

        event = {
            'test': True,
            'time': datetime.datetime(2012, 05, 01, 07, 27, 01, 200),
            'date': datetime.date(2012, 05, 07),
        }

Example 45

Project: datafari
Source File: test_xmlrpc.py
View license
    def test_datetime_before_1900(self):
        # same as before but with a date before 1900
        dt = datetime.datetime(1, 02, 10, 11, 41, 23)
        s = xmlrpclib.dumps((dt,))
        (newdt,), m = xmlrpclib.loads(s, use_datetime=1)
        self.assertEqual(newdt, dt)
        self.assertEqual(m, None)

        (newdt,), m = xmlrpclib.loads(s, use_datetime=0)
        self.assertEqual(newdt, xmlrpclib.DateTime('00010210T11:41:23'))

Example 46

Project: chipsec
Source File: test_xmlrpc.py
View license
    def test_dump_bare_datetime(self):
        # This checks that an unwrapped datetime.date object can be handled
        # by the marshalling code.  This can't be done via test_dump_load()
        # since with use_datetime set to 1 the unmarshaller would create
        # datetime objects for the 'datetime[123]' keys as well
        dt = datetime.datetime(2005, 02, 10, 11, 41, 23)
        s = xmlrpclib.dumps((dt,))
        (newdt,), m = xmlrpclib.loads(s, use_datetime=1)
        self.assertEqual(newdt, dt)
        self.assertEqual(m, None)

        (newdt,), m = xmlrpclib.loads(s, use_datetime=0)
        self.assertEqual(newdt, xmlrpclib.DateTime('20050210T11:41:23'))

Example 47

Project: bbvisa2ofx
Source File: txtparser.py
View license
    def testUpdateInstallmentTransactionLine(self):
        obj = {}
        obj['value'] = 20.0
        obj['date'] = '20110504'
        obj['desc'] = 'ASDASDASDASDA PARC 02/04 FARROUPILHA   BR'
        obj['fitid'] = (obj['date'] + str(obj['value']) + obj['desc']).replace(' ','')

        self.parser.dueDate = datetime.datetime(2011,07,25)
        self.parser.updateDateFromInstallmentTransactionLine(obj)
        self.assertEquals(obj['date'], '20110604')

Example 48

Project: simian
Source File: applesus_test.py
View license
  def testGetSuccessWhereCatalogNotChanged(self):
    """Tests AppleSUS.get()."""
    track = 'stable'
    full_os_version = '10.6.6'
    major_minor_os_version = '10.6'
    client_id = {'track': track, 'os_version': full_os_version}
    session = 'session'
    catalog_date = datetime.datetime(2011, 01, 01)

Example 49

Project: SchoolIdolAPI
Source File: migrate_update4.py
View license
@transaction.atomic
def update_activities():
        print 'Update activities'
        total = 0
        for activity in models.Activity.objects.filter(creation__gte=datetime.datetime(2016, 07, 4, 0, 0, 0, 0, pytz.UTC), message_type__in=[0, 1]).select_related('ownedcard', 'ownedcard__card', 'account'):
                if '/' in activity.right_picture: # not imgur
                        activity.right_picture = ownedcardimageurl({}, activity.ownedcard, card=activity.ownedcard.card, english_version=(activity.account.language != 'JP'))
                        activity.save()
                        total += 1

Example 50

Project: python-googleanalytics
Source File: tests.py
View license
    def test_bad_date_order(self):
        start_date = datetime.date(2009, 02, 21)
        end_date = datetime.date(2009, 02, 20)
        account = self.connection.get_account(self.valid_profile_ids[0])
        try:
            data = account.get_data(start_date=start_date, end_date=end_date, metrics=['pageviews'])
        except GoogleAnalyticsClientError, e:
            assert str(e.reason) == "Date orders are reversed"