Example #1
0
 def test_looping_when_unknown_input(self):
     get_y_or_n(input=self.eventual_yes_input, output=self.log_output)
     self.assertEqual(
         'Continue? (y/n) ' +
         'Please enter y/n.' +
         'Continue? (y/n) ' +
         'Please enter y/n.' +
         'Continue? (y/n) ',
         self.full_log()
     )
Example #2
0
 def test_returns_false_for_no_input(self):
     self.assertFalse(
         get_y_or_n(
             input=self.no_input,
             output=self.log_output
         )
     )
Example #3
0
 def test_returns_true_for_yes_input(self):
     self.assertTrue(
         get_y_or_n(
             input=self.yes_input,
             output=self.log_output
         )
     )
Example #4
0
def sites_rename(arguments):
    """
    Renames the site in the current directory to the new sitename.

    Usage: widely sites:rename <SITENAME>
    """
    sites_copy(arguments)
    new_sitename = arguments['<SITENAME>']
    bucket = get_current_bucket()

    decision = get_y_or_n('Would you like to delete {0}?'.format(bucket.name))

    if decision:
        # Update the .widely to the new sitename
        with open('.widely', 'w') as f:
            f.write(new_sitename)
        bucket.delete_keys(bucket.get_all_keys())
        bucket.delete()
Example #5
0
def pull(arguments):
    """
    Pulls content associated with the specified sitename from AWS S3
    to the current directory.

    Usage: widely pull --site <SITENAME>
    """
    sitename = get_current_or_specified_sitename(arguments)
    bucket = get_current_or_specified_bucket(arguments)
    diffs = generate_diffs(bucket)
    if diffs:
        show_diffs(diffs)
        # Ask for approval
        if get_y_or_n("Would you like to make the changes locally?"):
            run_diffs(diffs, bucket, local_changes=True)
            # Set the .widely file (or create it) with the bucket name
            with open('.widely', 'w') as f:
                f.write(sitename)
    else:
        print('There are no changes to pull.')
Example #6
0
def push():
    """
    Pushes local content to AWS S3 for publication.

    Usage: widely push
    """
    bucket = get_current_bucket()
    diffs = generate_diffs(bucket)
    if diffs:
        show_diffs(diffs)
        # Ask for approval
        decision = get_y_or_n(
            'Would you like to make the changes in {0}?'.format(
                bucket.name
            )
        )
        if decision:
            run_diffs(diffs, bucket, local_changes=False)
    else:
        print('There are no changes to push.')
Example #7
0
 def test_message_appends_a_space_when_passing_in_a_message(self):
     get_y_or_n(message='abc', input=self.yes_input, output=self.log_output)
     self.assertStartsWith('abc ', self.full_log())
Example #8
0
 def test_message_defaults_to_continue(self):
     get_y_or_n(input=self.yes_input, output=self.log_output)
     self.assertStartsWith('Continue? (y/n)', self.full_log())