Skip to content

Commit 3cc69cc

Browse files
author
rightlag
committed
Update README.md, add more comments for unit tests
1 parent bd4248b commit 3cc69cc

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,15 @@ All commits are tested with [Travis CI](https://travis-ci.org/) and *also* requi
3939
>>> timely = Timely(verbose=True)
4040
>>> timely.check()
4141
Stopping instance: i-6dc5bc92
42+
43+
### Using timezones
44+
45+
By default, `timely` sets the default timezone to `US/Eastern`. However, this can be changed upon instantiation of the `timely` class or via the `set_tz` method. For example:
46+
47+
>>> from timely import Timely
48+
>>> timely = Timely(tz='US/Pacific')
49+
>>> timely.set_tz('US/Mountain')
50+
51+
If the timezone specified does not exist, then `UTC` is used.
52+
53+
When assigning the timezone, the `set` method will create a tag `tz` for EC2 containers with the timezone that was specified. Whenever the `check` method is called, the `tz` tag that is assigned to the EC2 container is used to determine whether or not it should be running.

tests/test_timely.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,17 @@ def setUp(self):
1414
self.conn = boto.ec2.connect_to_region('us-east-1')
1515
self.now = datetime.datetime.now(tz=pytz.timezone('US/Eastern'))
1616

17-
def test_times_tag_is_created(self):
17+
def test_times_and_tz_tags_are_created(self):
18+
"""Assert that both the `times` and `tz` tags are created for
19+
instances."""
1820
self.timely.set(weekdays=['*'])
1921
instances = self.conn.get_only_instances()
2022
for instance in instances:
2123
self.assertIn('times', instance.tags)
2224
self.assertIn('tz', instance.tags)
2325

2426
def test_times_tag_has_length_of_7(self):
27+
"""Assert that the length of the times tag is 7 elements."""
2528
self.timely.set(weekdays=['*'])
2629
instances = self.conn.get_only_instances()
2730
for instance in instances:
@@ -31,6 +34,7 @@ def test_times_tag_has_length_of_7(self):
3134
self.assertEqual(len(times), 7)
3235

3336
def test_time_is_set_for_weekday(self):
37+
"""Assert that a time is set for the current weekday."""
3438
weekday = self.timely.weekdays[self.now.weekday()]
3539
self.timely.set(weekdays=[weekday], start_time='9:00 AM',
3640
end_time='5:00 PM')
@@ -40,6 +44,9 @@ def test_time_is_set_for_weekday(self):
4044
self.assertNotEqual(times[self.now.weekday()], str(None))
4145

4246
def test_exception_if_start_time_is_greater_than_equal_to_end_time(self):
47+
"""If the start time is greater than or equal to the end time
48+
a `ValueError` should be raised.
49+
"""
4350
with self.assertRaises(ValueError):
4451
# Greater
4552
self.timely.set(weekdays=['*'], start_time='9:00 AM',
@@ -49,6 +56,7 @@ def test_exception_if_start_time_is_greater_than_equal_to_end_time(self):
4956
end_time='9:00 AM')
5057

5158
def test_unset_method(self):
59+
"""Assert that the times are set to `None` for all weekdays."""
5260
self.timely.set(weekdays=['*'], start_time='9:00 AM',
5361
end_time='5:00 PM')
5462
instances = self.conn.get_only_instances()

0 commit comments

Comments
 (0)