Welcome to tech! It’s not always an easy field to be in, but there are always fun challenges and I’ve enjoyed doing the work involved at nearly every step in my career. Since you’re new here and I’ve been around for over 20 years, I want to share some of the skills and habits I wish I knew when I started.

Read More

There has been much talk about voter and election fraud as the president seeks to delegitimize elections. He talks a lot about manual methods like stealing ballots or impersonating other voters. The truth is that election fraud like this is incredibly rare. The point of his words seems to have two purposes, both common conservative arguments:

  • Disenfranchise voters by increasing “security” with photo ids and limiting where and how voting can take place
  • Decrease confidence in elections by sowing doubt about election integrity, thus making it easier to call results into question and limiting turnout due to mistrust

The purpose of this post is to explore how election fraud by stealing ballots could be perpetuated, thus showing why it’s so rare. I will also talk about more effective methods of election fraud, many of which are already happening.

Read More

This post combines three things I love: teaching dogs cool tricks, helping people grow, and figuring out how to do it best. I want to show you how easily I work with both dogs and humans, where the skills overlap and how they differ, so you too can teach fun tricks and help your fellow humans get better.

Why assess understanding?

Assessing understanding is the key to improvement. If you know what you don’t know you can hone in on fixing that gap. Here’s the tricky part, though: understanding is fluid; without practice, our skills and knowledge atrophy. Thus, assessing understanding is a continuous process.

Read More

2020 has brought many life-changing events and here we sit with another one. George Floyd dying at the hands of police has sent us into a civil rights moment that I’ve never seen in my lifetime. I have hope that attitudes are changing among white people that may lead to the dismantling of structural racism. #BlackLivesMatter is mainstream and white people are speaking out in numbers I haven’t seen, but there’s still work to be done.

The intent of my post is to talk about the role I’ve found for myself and give ideas for other white people to continue the work we must do to eliminate systematic racism.

Read More

In the my last post, I reposted an article from 2018 about modifying a simple script to make it more testable. It’s been two years since I wrote that, and the way I evaluate testing needs for code has changed. Let’s look at that script again.

Requirements

The script I wrote emptied AWS S3 buckets of any objects to get them ready to be deleted. AWS won’t delete an S3 bucket if it has any objects (files or subdirectories) in it. Here were the requirements of my script:

  1. We stored buckets in each AWS region, but they all have a similar name: logs-${region}. We need to delete objects in these buckets.
  2. Sometimes there wouldn’t be a bucket for a region, but we need to check them all. If a bucket doesn’t exist or is empty, skip it and continue.
  3. Optimize for speed over quality. This is a one off script.

So, to test it, I’m not sure I need to test it to death. I need to make sure that it:

  • empties every bucket that matches the naming pattern
  • skips (and logs) any buckets that aren’t there
  • doesn’t die on any errors

Changes I’d Make

I want to make sure both the script and test(s) aren’t brittle. AWS updates its regions often enough that I don’t want to bury the region list too deeply. I also don’t want to hardcode the bucket we’re trying to empty.

On the testing side, this will also help me write tests that won’t break unless the requirements for the script change. So here are my changes:

  1. Make the bucket name an argument
  2. Make the region list an argument
  3. Mock AWS S3 to create tests around the three basic requirements:
  • make sure buckets are empty after running the script
  • make sure it skips and logs any buckets that don’t exist
  • make sure a bucket that doesn’t match the pattern is not emptied.

The Script

#!/usr/bin/env python3
import subprocess

def empty_buckets():

    regions = [
        'us-east-1',
        'us-east-2',
        'us-west-1',
        'us-west-2',
        'ca-central-1',
        'eu-west-1',
        'eu-west-2',
        'eu-central-1',
        'ap-south-1',
        'ap-southeast-1',
        'ap-southeast-2',
        'ap-northeast-1',
        'ap-northeast-2',
        'sa-east-1'
    ]

    bucket_template = 'fugue-e2e-s3-%s-logging'

    for r in regions:
        bucket_name =  bucket_template % (r)
        print('Verifying logging bucket in %s exists and contains objects.' % (r))
        call = "aws --region {} s3api head-bucket --bucket {}".format(r, bucket_name)

        try:
            subprocess.check_output([call, ""], shell=True)

            print('Bucket exists. Emptying.')
            output = subprocess.check_output(["aws --region {} s3 rm s3://{} --recursive".format(r, bucket_name), ""], shell=True)
            print(output.decode('utf-8'))
        except Exception as e:
            print('Error: logging bucket in %s %s' % (r, e))

If you’ve been looking around for information on unit testing and want to know a bit more, or possibly see an example of how to put it into practice, you’re in the right place.

By the end of this blog post, you should be able to:

  • Look over parts of your code where you’d like to add unit tests.
  • Understand how to break your code into smaller functions.
  • Determine what to test.
  • Start creating your tests.

We’ll also cover rudimentary mocking, which is the practice of writing pretend calls to test your code against predictable values.

Read More

As I write this, I’m entering my sixth week home with my family: a 2 and 4 year old, my husband, and my grandmother. My husband and I both are working and my grandmother lives for my children, so we’re in a good place. We all like each other and are making the best of this.

It’s been up and down, joy and stress, caring and frustration. Mostly it’s been stable and steady. This got me thinking about how I’m feeling fine enough when others in similar situations are struggling.*

Read More

I don’t care who or what you’re working with, if they’re sentient, they all want to:

  • be right
  • feel smart
  • be praised
  • feel accepted or loved or cared for (or all three)

When they don’t know what to do or get it wrong, they want to:

  • be taught how to be right
  • know they’re still accepted
  • understand how to make amends if they messed something up

So:

Read More

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×