Ejemplo n.º 1
0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
description: create tasks with a single command
"""
from __future__ import print_function
import simcity
import sys
import argparse

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="create new tasks in the database")
    parser.add_argument("command", help="command to run")
    parser.add_argument("-n", "--number", type=int, help="number of tasks to create", default=1)
    parser.add_argument("-c", "--config", help="configuration file", default=None)
    args = parser.parse_args()

    simcity.init(config=args.config)

    # Load the tasks to the database
    for i in range(args.number):
        try:
            simcity.add_task({"command": args.command})
            print("added task %d" % i)
        except:
            print("ERROR: task %d failed to be added" % i, file=sys.stderr)
Ejemplo n.º 2
0
def test_add_task():
    simcity.management.set_task_database(MockDB())
    task = simcity.add_task({'key': 'my value'})
    assert_equal(task['key'], 'my value')
    assert_true(len(task.id) > 0)